package com.hejing.bpeldesign.bpelprase;

import com.hejing.bpeldesign.model.BpelNode;
import com.hejing.bpeldesign.model.DefaultNode;
import org.w3c.dom.Element;

import java.util.UUID;

public class DefaultParser  implements NodeParserStrategy{
    @Override
    public BpelNode parse(Element el) {
        String id = UUID.randomUUID().toString();
        String name = el.getAttribute("name");
        String bounds = el.getAttribute("bounds");
        String[] parts = bounds.split(",");
        return new DefaultNode(id, name, el.getTagName(),
                Integer.parseInt(parts[0]),
                Integer.parseInt(parts[1]),
                Integer.parseInt(parts[2]),
                Integer.parseInt(parts[3]));
    }
}
